package com.smt.modules.bus.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import com.smt.common.base.BaseController;
import com.smt.modules.bus.vo.DocPageVo;
import com.smt.modules.bus.entity.DocPageEntity;
import com.smt.modules.bus.service.DocPageService;
import com.smt.common.utils.PageUtils;
import com.smt.common.utils.R;



/**
 * 打包文件
 *
 * @author murong
 * @email 981620741@qq.com
 * @date 2018-11-13 11:04:05
 */
@RestController
@RequestMapping("bus/docpage")
@Api(tags = {"DocPageController"},description = "打包文件")
public class DocPageController extends BaseController{
    @Autowired
    private DocPageService docPageService;

    /**
    * 查询打包文件分页方法
    * @param params
    * @return
    */
    @PostMapping("/list")
    @RequiresPermissions("bus:docpage:list")
    @ApiOperation(value = "/list",notes = "根据条件查询",response = DocPageVo.class)
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = docPageService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    @RequiresPermissions("bus:docpage:info")
    @ApiOperation(value = "/info/{id}",notes = "根据表ID查询",response = DocPageVo.class)
    public R info(@PathVariable("id") Long id){
			DocPageEntity docPage = docPageService.selectById(id);

        return R.ok().put("docPage", docPage);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    @RequiresPermissions("bus:docpage:save")
    @ApiOperation(value = "/save",notes = "添加信息保存",response = DocPageVo.class)
    public R save(@RequestBody DocPageEntity docPage){
			docPageService.insert(docPage.copyPropertiesTo(new DocPageEntity()));

        return R.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    @RequiresPermissions("bus:docpage:update")
    @ApiOperation(value = "/update",notes = "更新信息保存",response = DocPageVo.class)
    public R update(@RequestBody DocPageEntity docPage){
			docPageService.updateById(docPage.copyPropertiesTo(new DocPageEntity()));

        return R.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
    @RequiresPermissions("bus:docpage:delete")
    @ApiOperation(value = "/delete",notes = "批量删除",response = DocPageVo.class)
    public R delete(@RequestBody Long[] ids){
			docPageService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }

}
